package com.cn.lp.ai.factory;


import jakarta.annotation.Resource;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.qianfan.QianFanEmbeddingModel;
import org.springframework.ai.qianfan.api.QianFanApi;
import org.springframework.ai.vectorstore.RedisVectorStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import redis.clients.jedis.JedisPooled;

//@Configuration
public class RedisConfig {

    @Autowired
    private QianFanEmbeddingModel qianFanEmbeddingModel;

    @Bean
    public JedisPooled getJedisPooled() {
        return new JedisPooled("redis://192.168.0.139:6379");
    }

//    @Bean
//    @Primary
//    public RedisVectorStore vectorStore() {
//        RedisVectorStore.RedisVectorStoreConfig config = RedisVectorStore.RedisVectorStoreConfig.builder()
//                .withURI("redis://192.168.0.139:6379")
//                .withIndexName("rag_index")
//                .withPrefix("rag:")
//                .withMetadataFields(
//                        RedisVectorStore.MetadataField.text("filename"),
//                        RedisVectorStore.MetadataField.text("question"))
//                .build();
//        return new RedisVectorStore(config, qianFanEmbeddingModel,getJedisPooled(), true);
//    }

//    @Bean
//    @Primary
//    public EmbeddingModel qianFanAiEmbeddingModel() {
//        // Can be any other EmbeddingModel implementation.
//        return new QianFanEmbeddingModel(new QianFanApi("MvysR72993WVTDGDIEaAn6WP", "ic0E8B4ZsXO9XoHgweGgntpnAIpOvGxF"));
//    }

}
